<?php

namespace App\Models\Saleprice;

use Illuminate\Database\Eloquent\Model;

class Saleprice extends Model
{
    protected $table = 'sale_price';
    public $timestamps = false;
    protected $primaryKey = 'id';
    protected $guarded = ['_token'];

    /**
     * 列表
     */
    public static function getlist($request, $mangerinfo, $isgetall)
    {
        $cpid = $mangerinfo['cpid'] ?? 0;
        $query = self::where(['cpid' => $cpid, 'is_del' => config('constants.is_del.yes')])
            ->orderBy('del_at', 'desc');

        if ($isgetall == 0) {
            $limit = $request->limit ?? 10;
            $list = $query->paginate($limit)->toArray();
            return paginateDataToArray($list);
        } else {
            $list = $query->get()->toArray();
            return ['list' => $list];
        }
    }
}
